home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-06-22 | 4.2 KB | 175 lines | [TEXT/McSk] |
- \ ctlWind - Window subclass adding controls etc.
-
- \ May 91 mrh Extensively revised adding standard vert & horiz scroll bar
- \ and zoom box support.
-
- decimal
-
- need ctl
- need vscroll
-
- objPtr theSB class_is vscroll
- 0 value MPOINT
-
-
- : CTLEXEC \ ( part# ctlHndl -- ) Executes action for control.
- get-ctl-obj exec: ** ;
-
- \ CtlProc is the procedure to be executed when a control is being tracked.
-
- :proc CTLPROC \ ( ctlHndl int:part -- )
- word0 swap ctlExec ;proc
-
-
- : CTLHIT? { wind \ part ^ctl action1 action2 -- bool }
- \ Look for control click
- where: fEvent g->l -> mpoint \ save mouse loc
- word0 mpoint wind theCtl call FindControl
- word0 -> part theCtl @ -> ^ctl \ ctl handle
- part
- CASE[ inThumb ], [ inCheckBox ], [ inButton ]=>
- \ Only exec after mouseUp
- 0 -> action1 \ 0 since gets passed to TrackControl
- ['] ctlExec -> action2
- DEFAULT=>
- drop ['] ctlproc -> action1 ['] 2drop -> action2
- ]CASE
- ^ctl
- IF
- word0 ^ctl mpoint action1 call TrackControl word0
- ^ctl action2 execute true
- ELSE
- false
- THEN ;
-
-
- \ Note: if your Window is a subclass of CtlWind and has scroll bars,
- \ it should set the scroll bars to 255 hiliting on a deactivate event.
- \ This can be done via the Disable: method in VScroll. But if the scroll
- \ bars are default ones set up via setVscroll: and setHscroll:, this
- \ will all be looked after for you.
-
-
- :class CTLWIND super{ window }
-
- ptr ^VSCROLL
- ptr ^HSCROLL
-
- bool ZOOMFLG
-
- private
-
- :m VSCROLL?: get: ^vscroll nilP <> ;m
-
- :m HSCROLL?: get: ^hscroll nilP <> ;m
-
- :m ?SBtoEdge:
- vscroll?: self IF get: ^vscroll edge: vscroll THEN
- hscroll?: self IF get: ^hscroll edge: hscroll THEN ;m
-
- public
-
- :m SETZOOM: \ ( b -- ) Passed-in boolean indicates if this window will be
- \ zoomable.
- put: zoomFlg ;m
-
- :m SETVSCROLL: { vscr lo hi \ left top rt bot -- }
-
- \ Sets up a vertical scroll bar in the usual position. vscr is the addr of
- \ a vscroll object, and lo and hi gives the range. All the housekeeping for
- \ the scroll bar is looked after automatically.
-
- vscr put: ^vscroll vscr -> theSB
- getVrect: self
- -> bot -> rt -> top -> left
- left top bot 1+ ^base new: theSB
- lo hi putRange: theSB ;m
-
- :m SETHSCROLL: { hscr lo hi \ left top rt bot -- }
-
- \ Sets up a horizontal scroll bar in the usual position.
-
- hscr put: ^hscroll hscr ['] theSB ! ( strictly, classes don't match )
- getHrect: self
- -> bot -> rt -> top -> left
- left top rt 1+ ^base new: theSB
- lo hi putRange: theSB
- setView: self ;m
-
- :m NEW: { bndsRect tAddr tLen procID vis goAway \ s255 -- }
-
- \ Defines a new window on the heap with the specified features.
- \ Not resource based. Only change in this subclass is to use
- \ zoomFlg to modify the procID.
-
- get: alive ?EXIT \ Out if already alive
- ?disable_actW: self
- tAddr tLen str255 -> s255
- 0 ^base bndsrect s255 vis Tbool
- get: zoomFlg 8 and procID + makeint
- inFront goAway Tbool 0
- call NewWindow drop
- initNewWindow: self ;m
-
- :m GROW: grow: super ?SBtoEdge: self ;m
-
- :m ZOOM: zoom: super set: super ?SBtoEdge: self ;m
-
- :m ENABLE:
- vscroll?: self IF get: ^vscroll enable: vscroll THEN
- hscroll?: self IF get: ^hscroll enable: hscroll THEN
- enable: super ;m
-
- :m DISABLE:
- vscroll?: self IF get: ^vscroll disable: vscroll THEN
- hscroll?: self IF get: ^hscroll disable: hscroll THEN
- disable: super ;m
-
-
- :m DRAW: \ Draws the window with controls
- draw: super ^base call DrawControls ;m
-
- :m CLOSE: \ Disposes of window's controls and closes the window
- ^base call KillControls close: super ;m
-
- :m CONTENT: \ Handles a content click
- active: self
- IF
- ^base ctlHit?
- NIF exec: content THEN
- ELSE
- select: self
- THEN ;m
-
- :m TEST:
- 100 100 300 200 put: tempRect
- screenbits true setGrow: self
- tempRect " Test" docWind true true new: self
- true setZoom: self ;m
-
- ;class
-
- endload
-
- \ TESTING:
-
- ctlWind WW
- hscroll VV1
- vscroll VV2
-
- screenbits true setGrow: ww
- true setZoom: ww
-
- : GO
- CFAS{ lnup lndn null null null } actions: vv1
- CFAS{ lnup lndn null null null } actions: vv2
- test: ww vv1 0 20 sethscroll: ww vv2 0 10 setvscroll: ww ;
-
- : RR \ Test getting things from a resource file
- " WindTest.rsrc" openresfile
- 128 db getNew: ww
- 128 ww getNew: vv1 ;
-
-
- : ZZ set: fwind close: vv1 close: vv2 close: ww ;
-